package com.shujia.controller;

import com.shujia.bean.Message;
import com.shujia.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {


    private UserService userService = new UserService();

    /**
     * http://192.168.3.108:8080/login?username=zhaoliu&password=123456
     *
     * @param username 用户米
     * @param password 密码
     * @return 登录情况
     */

    @GetMapping("/login")
    public Message login(String username, String password) {

        Message login = userService.login(username, password);


        /**
         * spring 会自动将一个java对象转换成json格式的数据返回给前端
         *
         */
        return login;
    }

    @GetMapping("/register")
    public Message register(String username, String password, String nowPassword) {

        Message register = userService.register(username, password, nowPassword);

        return register;
    }


    @GetMapping("modifyPassword")
    public Message modifyPassword(String username, String password, String newPassword, String nowPassword) {

        Message message = userService.modifyPassword(username, password, newPassword, nowPassword);

        return message;
    }


}
